package org.unideb.beerfactory.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.unideb.beerfactory.dto.MaterialDTO;
import org.unideb.beerfactory.entity.Material;

@Repository
public interface MaterialDao extends PagingAndSortingRepository<Material, Long>,
        BaseConvertDao<Material, MaterialDTO> {

    Page<Material> findByMaterialNameStartsWith(String materialName, Pageable pageable);

    @Query(value = "SELECT count(*) FROM MATERIAL", nativeQuery = true)
    int countById();

}
